﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class AssetCodeMaintan : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            GridView1.Visible = false;
            FormView1.Visible = false;
        }
    }
    protected void queryBtn_Click(object sender, EventArgs e)
    {
        displaymode();
    }
    private void insertmode()
    {
        FormView1.Visible = true;
        GridView1.Visible = false;
    }
    private void displaymode()
    {
        FormView1.Visible = false;
        GridView1.Visible = true;
        GridView1.DataBind();
    }
    protected void insertBtn_Click(object sender, EventArgs e)
    {
        insertmode();
    }
    protected void FormView1_ItemInserted(object sender, FormViewInsertedEventArgs e)
    {
        Common.UI.ShowMessageBox(this.Page, "新增資料成功");
        displaymode();
    }
    protected void FormView1_ItemCommand(object sender, FormViewCommandEventArgs e)
    {
        displaymode();
    }
    protected void FormView1_DataBound(object sender, EventArgs e)
    {
        FormView fv = (FormView)sender;
        if(fv.DefaultMode == FormViewMode.Insert)
        {
            TextBox tb = (TextBox)fv.FindControl("ItemTypeTextBox");
            tb.Text = "AssetCode";
        }
    }
    protected void GridView1_RowDeleted(object sender, GridViewDeletedEventArgs e)
    {
        Common.UI.ShowMessageBox(this.Page, "資料刪除成功");
        displaymode();
    }
}
